package com.frxuexi.shop.adapter

import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.room.OrderEntity
import com.frxuexi.lib_base.utils.GlideUtils
import com.frxuexi.shop.R

class OrderAdapter:BaseQuickAdapter<OrderEntity,BaseViewHolder>(R.layout.item_order) {
    override fun convert(helper: BaseViewHolder, item: OrderEntity) {
        GlideUtils.loadRoundImage(item.img,helper.getView(R.id.order_iv))
        helper.setText(R.id.order_title,item.sname)
        helper.setText(R.id.order_num,"×${item.num}")
        helper.setText(R.id.order_price,"￥${item.price}")
        helper.setText(R.id.order_sum,"￥${item.num*item.price}")

        helper.getView<TextView>(R.id.btn_order).apply {
            helper.getView<TextView>(R.id.btn_no).let {
                it.visibility=View.VISIBLE
                visibility=View.VISIBLE
                when(item.status){
                    1-> {
                        it.setText("取消订单")
                        setText("去支付")
                    }
                    2-> {
                        it.setText("取消订单")
                        setText("发货")
                    }
                    3->{
                        it.setText("退货")
                        setText("确认收获")
                    }
                    4-> {
                        it.setText("退货")
                        setText("去评价")
                    }
                    5->{
                        it.visibility=View.GONE
                        visibility=View.GONE
                    }
                }
            }

        }

    }
}